package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.PageHelper;
import com.google.gson.annotations.Until;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.NursingProjectPlansDto;
import com.zzyl.mapper.NursingPlanMapper;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.ProjectPlansVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @version 1.0
 * @description 说明
 * @package com.zzyl.service.impl
 */
@Service
public class NursingPlanServiceImpl implements NursingPlanService {
    @Resource
    private NursingPlanMapper nursingPlanMapper;
    @Override
    public PageResponse<NursingPlanVo> search(String planName, Integer pageNum, Integer pageSize, Integer status) {
        PageHelper.startPage(pageNum, pageSize);
        List<NursingPlanVo> nursingPlanVos = nursingPlanMapper.selectPage(planName, status);
        return PageResponse.of(nursingPlanVos);
    }

    @Override
    public List<NursingPlanVo> findById(Long id) {
       return nursingPlanMapper.selectNursingPlanWithProjects(id);
    }

    @Override
    @Transactional
    public void addNursingProject(NursingProjectPlansDto nursingProjectPlansDto) {
        NursingPlanVo bean = BeanUtil.toBean(nursingProjectPlansDto, NursingPlanVo.class);
           Long id = nursingPlanMapper.insert(bean);

    }


}
